home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / QUERYDSP.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-14  |  3KB  |  70 lines

  1. {->>>>QueryAdapterType<<<<-------------------------------------}
  2. {                                                              }
  3. { Filename : QUERYDSP.SRC -- Last Modified 7/11/88             }
  4. {                                                              }
  5. { This routine determines the currently installed primary      }
  6. { display adapter and returns it in the form of a value from   }
  7. { the enumerated type AdapterType.                             }
  8. {                                                              }
  9. { AdapterType must be predefined:                              }
  10. {                                                              }
  11. { AdapterType = (None,MDA,CGA,EGAMono,EGAColor,VGAMono,        }
  12. {                 VGAColor,MCGAMono,MCGAColor);                }
  13. {                                                              }
  14. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  15. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  16. {--------------------------------------------------------------}
  17.  
  18. FUNCTION QueryAdapterType : AdapterType;
  19.  
  20. VAR
  21.   Regs : Registers;
  22.   Code : Byte;
  23.  
  24. BEGIN
  25.   Regs.AH := $1A;  { Attempt to call VGA Identify Adapter Function }
  26.   Regs.AL := $00;  { Must clear AL to 0 ... }
  27.   Intr($10,Regs);
  28.   IF Regs.AL = $1A THEN  { ...so that if $1A comes back in AL...  }
  29.     BEGIN                { ...we know a PS/2 video BIOS is out there. }
  30.       CASE Regs.BL OF    { Code comes back in BL }
  31.         $00 : QueryAdapterType := None;
  32.         $01 : QueryAdapterType := MDA;
  33.         $02 : QueryAdapterType := CGA;
  34.         $04 : QueryAdapterType := EGAColor;
  35.         $05 : QueryAdapterType := EGAMono;
  36.         $07 : QueryAdapterType := VGAMono;
  37.         $08 : QueryAdapterType := VGAColor;
  38.         $0A,$0C : QueryAdapterType := MCGAColor;
  39.         $0B : QueryAdapterType := MCGAMono;
  40.         ELSE QueryAdapterType := CGA
  41.       END { CASE }
  42.     END
  43.   ELSE
  44.   { Next we have to check for the presence of an EGA BIOS: }
  45.     BEGIN
  46.       Regs.AH := $12;       { Select Alternate Function service }
  47.       Regs.BX := $10;       { BL=$10 means return EGA information }
  48.       Intr($10,Regs);       { Call BIOS VIDEO }
  49.       IF Regs.BX <> $10 THEN { BX unchanged means EGA is NOT there...}
  50.         BEGIN
  51.           Regs.AH := $12;   { Once we know Alt Function exists... }
  52.           Regs.BL := $10;   { ...we call it again to see if it's... }
  53.           Intr($10,Regs);   { ...EGA color or EGA monochrome. }
  54.           IF (Regs.BH = 0) THEN QueryAdapterType := EGAColor
  55.             ELSE QueryAdapterType := EGAMono
  56.         END
  57.       ELSE  { Now we know we have an EGA or MDA: }
  58.         BEGIN
  59.           Intr($11,Regs);   { Equipment determination service }
  60.           Code := (Regs.AL AND $30) SHR 4;
  61.           CASE Code of
  62.             1 : QueryAdapterType := CGA;
  63.             2 : QueryAdapterType := CGA;
  64.             3 : QueryAdapterType := MDA
  65.             ELSE QueryAdapterType := CGA
  66.           END { Case }
  67.         END
  68.     END;
  69. END;
  70.